package com.sdhs.think.modules.gen.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.sdhs.think.modules.gen.entity.GenTable;
import com.sdhs.think.modules.gen.entity.GenTableColumn;
import com.sdhs.think.modules.gen.service.GenTableService;

@Controller
@RequestMapping(value = "gen")
public class GenTableController {
	
	@Autowired
	private GenTableService genTableService;
	
	@RequestMapping("gendb")
	public String getTableFromDb(){
		GenTable genTable = new GenTable();
		genTable.setName("firsttest");
		/*List<GenTable> list = genTableService.findTableList(genTable );
		for(GenTable table : list){
			System.out.println(table);
		}*/
		List<GenTableColumn> list = genTableService.findTableColumnList(genTable);
		for(GenTableColumn m :list){
			System.out.println(m.toString());
		}
		return "test";
	}
	
	@RequestMapping(value = "form")
	public String form(Model model){
		GenTable genTable = new GenTable();
		List<GenTable> list = this.genTableService.findTableList(genTable);
		model.addAttribute("tableList", list);
		model.addAttribute("genTable", genTable);
		return "modules/gen/genTableForm";
	}
	

}
